package dizhu;

import java.util.ArrayList;
import java.util.Collections;

public class PackCards {
	ArrayList<Card> cards;
	

	public ArrayList<Card> getCards() {
		return cards;
	}	

	public PackCards() {//构造方法，生成一副牌对象
		this.cards=new ArrayList<>();
		
		ArrayList<String> color=new ArrayList<String>();
		ArrayList<String> number=new ArrayList<String>();
		
		color.add("♠");
		color.add("♥");
		color.add("♦");
		color.add("♣");
		
		for (int i = 3; i <= 10; i++) {
			number.add(i + "");
		}
		number.add("J");
		number.add("Q");
		number.add("K");
		number.add("A");
		number.add("2");
		
		int index=1;		
		for (String thisNumber : number) {// 循环纸牌数字
			for (String thisColor : color) {// 循环纸牌花色
				// 将花色与数字组合，形成52张牌，并赋予其编号
				cards.add(new Card(index++,thisColor+thisNumber));
			}
		}
		cards.add(new Card(index++,"小☺"));
		cards.add(new Card(index++,"大☻"));	
	}
	
	public void shuffleCards() {
		//洗牌方法
		Collections.shuffle(cards);
	}
	
	public String toString() {//看牌方法
		StringBuffer sb=new StringBuffer();
		for(Card c:cards) {
			sb.append(c.getCardStr()+",");
		}
		return sb.toString();
	}
	
	

}
